#include "networkmanager.h"
#include "netparam.h"
NetworkManager::NetworkManager(QObject *parent) :
    QObject(parent)
{
    client = new Client(this);
    connect(client,SIGNAL(recieveData(QString,QByteArray)),this,SIGNAL(recieveData(QString,QByteArray)));
    connect(client,SIGNAL(notify(QString,int)),this,SIGNAL(notify(QString,int)));

    // the server signals
    connect(client,SIGNAL(recieveServerData(QByteArray)),SIGNAL(recieveServerData(QByteArray)));
    connect(client,SIGNAL(serverNotify(int)),SIGNAL(serverNotify(int)));
}

QString NetworkManager::getIp()
{
    return Client::getIp();
}

void NetworkManager::onSendData(QString ip, QByteArray data)
{
    qDebug("in network manager, send data");
    if(!client) return;
    printf("ip=%s,data=%s\n",ip.toAscii().data(),data.data());
    client->onSendData(ip,data);

}





void NetworkManager::onNotify(QString ip, int code)
{
    qDebug("in client,ip:%s,code:%d",ip.toAscii().data(),code);
}
void NetworkManager::onRecieveData(QString ip, QByteArray data)
{
    qDebug("in network manager,recieve data from ip %s ",ip.toAscii().data());
}

void NetworkManager::onSendServerData(QByteArray data)
{
    if(!client) return;
    client->onSendServerData(data);
}

